//
//  GJMacro.h
//  xmgjAppFront
//
//  Created by Zeki on 2020/7/8.
//  Copyright © 2020 guojutech. All rights reserved.
//

#ifndef GJMacro_h
#define GJMacro_h
/**
Synthsize a weak or strong reference.
 Example:
 @weakify(self)
 [self doSomething^{
 @strongify(self)
 if (!self) return;
 ...
 }];
 
 */
#ifndef weakify
#if DEBUG
#if __has_feature(objc_arc)
#define weakify(object) autoreleasepool{} __weak __typeof__(object) weak##_##object = object;
#else
#define weakify(object) autoreleasepool{} __block __typeof__(object) block##_##object = object;
#endif
#else
#if __has_feature(objc_arc)
#define weakify(object) try{} @finally{} {} __weak __typeof__(object) weak##_##object = object;
#else
#define weakify(object) try{} @finally{} {} __block __typeof__(object) block##_##object = object;
#endif
#endif
#endif

#ifndef strongify
#if DEBUG
#if __has_feature(objc_arc)
#define strongify(object) autoreleasepool{} __typeof__(object) object = weak##_##object;
#else
#define strongify(object) autoreleasepool{} __typeof__(object) object = block##_##object;
#endif
#else
#if __has_feature(objc_arc)
#define strongify(object) try{} @finally{} __typeof__(object) object = weak##_##object;
#else
#define strongify(object) try{} @finally{} __typeof__(object) object = block##_##object;
#endif
#endif
#endif

//log
#ifdef DEBUG
#define GJLog(FORMAT, ...) fprintf(stderr,"%s\n",[[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);
#else
#define GJLog(...)
#endif


// 获得RGB颜色
#define rgb(r,g,b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1.0]
#define rgba(r,g,b,a) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:a]

#define HexColor(_hex_)   [UIColor colorWithHexString:((__bridge NSString *)CFSTR(#_hex_))]

// 尺寸
#define kMainScreenScale [UIScreen mainScreen].scale // 屏幕scale
#define kSeparatorLineHeight (1.f/kMainScreenScale) // 水平分割线的高度
#define kLineHeight44 44.f
#define kAnimationDuration25 0.25

//iphoneX适配规则
#define isIphoneX (kScreenHeight >= 812.0 || kScreenWidth >= 812.0)
#define isIphone5 (kScreenWidth == 320)
#define isIphoneP (kScreenWidth == 414)
#define kSafeNavigationBarHeight (isIphoneX ? 88 : 64)
#define kSafeStatusBarHeight (isIphoneX ? 44 : 20)
#define kSafeTabBarHeight (isIphoneX ? 83 : 49)
#define kSafeBottomAreaHeight (isIphoneX ? 34 : 0)
// 系统版本判断
#define iOS10 ([[UIDevice currentDevice].systemVersion floatValue] >= 10.0)
#define iOS11 ([[UIDevice currentDevice].systemVersion floatValue] >= 11.0)
#define iOS13 ([[UIDevice currentDevice].systemVersion floatValue] >= 13.0)

#define WeakSelf __weak __typeof(&*self) weakSelf = self

// 3x 字体放大1.05倍, 最好在17号及以下字体使用
#define kSystemFontOfSize(size) [UIFont systemFontOfSize:(kScreenScale == 3 ? (size * 1.05) : size)]
#define kMediumSystemFontOfSize(size) [UIFont systemFontOfSize:(kScreenScale == 3 ? (size * 1.05) : size) weight:UIFontWeightMedium]
#define kBoldSystemFontOfSize(size) [UIFont boldSystemFontOfSize:(kScreenScale == 3 ? (size * 1.05) : size)]



//高德地图APPkey
#define GJAMapApiKey @"4fcb87c12c284958aef078078c152514"
//通知
#define GJKPayResultNotification @"GJKPayResultNotification"//通知支付结果
#define GJKChooseAddressResultNotification @"GJKChooseAddressResultNotification"//通知支付结果
#define GJKOpenPayPlatformNotification @"GJKOpenPayPlatformNotification"//跳转返回

#define GJKGJCommonEmitterNotification @"GJKGJCommonEmitterNotification"//RN通用监听通知
#define GJKGJChangeRNOrientationNotification @"GJKGJChangeRNOrientationNotification"//RN视图旋转横屏
#endif /* GJMacro_h */
